package com.ctgu.zmc;

/**
 * @author ZMC
 */
public class MyArray {

    /**
     * @return 返回连续子数组最大和
     */
    public static int maxSubSumOfSequence(int[] nums) {
        if (nums == null) {
            System.out.println("数组为null，请重新设置数组对象!");
            System.exit(0);
        } else if (nums.length == 0) {
            System.out.println("数组长度为0，请重新设置数组对象!");
            System.exit(0);
        }
        int nowSum = 0;
        int maxSum = nums[0];
        for (Integer num : nums) {
            if (nowSum < 0) {
                nowSum = num;
            } else {
                nowSum += num;
            }
            maxSum = Math.max(maxSum, nowSum);
        }
        return maxSum;
    }

}
